package cn.v2tila.rsosa.student.service.serviceImpl;

import cn.v2tila.rsosa.student.entity.VitaeEntity;
import cn.v2tila.rsosa.student.jpa.VitaeJPA;
import cn.v2tila.rsosa.student.service.VitaeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @author v2tila on 21:15 2019/3/31
 */
@Service
public class VitaeServiceImpl implements VitaeService {
    @Autowired
    private VitaeJPA vitaeJPA;

    @Override
    public VitaeEntity saveAndFlush(VitaeEntity vitaeEntity) {
        return vitaeJPA.saveAndFlush(vitaeEntity);
    }

    @Override
    public List<VitaeEntity> findByUniqueId(String uniqueId){
        return vitaeJPA.findByUniqueId(uniqueId);
    }

    @Override
    public void deleteById(Integer id) {
        vitaeJPA.deleteById(id);
    }

    public VitaeEntity findById(Integer id) {
        Optional<VitaeEntity> findResult = vitaeJPA.findById(id);
        return findResult.get();
    }

    @Override
    public VitaeEntity findByTitle(String title) {
        return vitaeJPA.findByTitle(title);
    }





}
